# Contributor: <xmingske@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=dnssec-tools
pkgver=2.2.3
pkgrel=7
pkgdesc="Set of tools that will help ease the deployment of DNSSEC"
url="https://dnssec-tools.org/"
arch="all"
license="BSD-3-Clause"
depends="perl-net-dns-sec perl-mailtools"
makedepends="autoconf automake bind-dev libtool openssl-dev perl-graphviz perl-crypt-openssl-random
	     perl-net-dns perl-xml-simple perl-dev sed chrpath"
source="https://github.com/DNSSEC-Tools/DNSSEC-Tools/archive/dnssec-tools-$pkgver.tar.gz"
subpackages="$pkgname-dev $pkgname-doc"

builddir="${srcdir}/DNSSEC-Tools-${pkgname}-${pkgver}/${pkgname}"

prepare() {
	local pf
	update_config_guess
	update_config_sub
	default_prepare
	sed -e '/^maninstall:/,+3s:$(MKPATH) $(mandir)/$(man1dir):$(MKPATH) $(DESTDIR)/$(mandir)/$(man1dir):' \
		-i Makefile.in
	sed -e 's:/usr/local/etc:/etc:g' \
		-e 's:/usr/local:/usr:g' \
		-i tools/donuts/donuts \
		-i tools/etc/dnssec-tools/dnssec-tools.conf \
		-i tools/scripts/genkrf
}

build() {
	CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE=1" ./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-bind-checks \
		--with-validator \
		--with-perl-build-args=INSTALLDIRS=vendor
	make
}

package() {
	mkdir -p "$pkgdir"/usr/share/man/man1
	make DESTDIR="$pkgdir" install
	chrpath -d "$pkgdir"/usr/bin/dt-*
}

sha512sums="fd2467f116f77089bddf9311706f356957f4ae735d827d393534e4001b621c9dfc904ff3d4da698d37e8e97b1be9448ab2fd5455c124656399aac30f1f642baf  dnssec-tools-2.2.3.tar.gz"
